package com.powerteam.service.masterData.Impl;

import com.alibaba.fastjson.JSON;
import com.powerteam.mapper.masterData.DistrictMapper;
import com.powerteam.model.masterData.District;
import com.powerteam.service.masterData.DistrictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 地区相关服务接口实现
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2021/12/30
 */
@Slf4j
@Service
public class DistrictServiceImpl implements DistrictService {

    private static final String CLASS_NAME = "DistrictServiceImpl";

    @Autowired
    private DistrictMapper districtMapper;

    @Override
    public List<District> findArea(Integer pid) {

        try {
            List<District> districtList = districtMapper.findArea(pid);
            log.info("{} findArea 查找地区信息 入参0:{} 结果0:{}", CLASS_NAME, pid, JSON.toJSON(districtList));

            return districtList;
        } catch (Exception e) {
            log.warn("{} findArea 查找地区信息异常 入参0:{}", CLASS_NAME, pid);
            log.error(e.getMessage(), e);
            return new ArrayList<>();
        }
    }

}
